package com.njtoyo.netrides.entity;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by astropete on 2017/8/16.
 */
@Entity
@Table(name = "commodity_order", schema = "netrides", catalog = "")
public class CommodityOrder {
    private long id;
    private String number;
    private long userId;
    private long productId;
    private Date createdAt;
    private Date updatedAt;

    @Id
    @Column(name = "id", nullable = false)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "number", nullable = false, length = 32)
    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Basic
    @Column(name = "user_id", nullable = false)
    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "product_id", nullable = false)
    public long getProductId() {
        return productId;
    }

    public void setProductId(long productId) {
        this.productId = productId;
    }

    @Basic
    @Column(name = "created_at", nullable = false)
    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @Basic
    @Column(name = "updated_at", nullable = true)
    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CommodityOrder goodOrder = (CommodityOrder) o;

        if (id != goodOrder.id) return false;
        if (userId != goodOrder.userId) return false;
        if (productId != goodOrder.productId) return false;
        if (number != null ? !number.equals(goodOrder.number) : goodOrder.number != null) return false;
        if (createdAt != null ? !createdAt.equals(goodOrder.createdAt) : goodOrder.createdAt != null) return false;
        if (updatedAt != null ? !updatedAt.equals(goodOrder.updatedAt) : goodOrder.updatedAt != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (number != null ? number.hashCode() : 0);
        result = 31 * result + (int) (userId ^ (userId >>> 32));
        result = 31 * result + (int) (productId ^ (productId >>> 32));
        result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
        result = 31 * result + (updatedAt != null ? updatedAt.hashCode() : 0);
        return result;
    }
}
